package com.qezhhnjy.mall.order.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.order.OrderOperateHistory;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.order.service.OrderOperateHistoryService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单操作历史记录 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "订单操作历史记录接口")
@Slf4j
@RequestMapping("/order-operate-history")
public class OrderOperateHistoryController {
    @Resource
    private OrderOperateHistoryService orderOperateHistoryService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取订单操作历史记录信息")
    public BaseResult<OrderOperateHistory> get(Long id) {
        OrderOperateHistory orderOperateHistory = orderOperateHistoryService.getById(id);
        return BaseResult.success(orderOperateHistory);
    }

    @PostMapping("/save")
    @Operation(summary = "新增订单操作历史记录信息")
    public BaseResult<OrderOperateHistory> save(@RequestBody OrderOperateHistory orderOperateHistory) {
        orderOperateHistoryService.save(orderOperateHistory);
        return BaseResult.success(orderOperateHistory);
    }

    @PutMapping("/update")
    @Operation(summary = "更新订单操作历史记录信息")
    public BaseResult<OrderOperateHistory> update(@RequestBody OrderOperateHistory orderOperateHistory) {
        orderOperateHistoryService.updateById(orderOperateHistory);
        return BaseResult.success(orderOperateHistory);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取订单操作历史记录信息")
    public BaseResult<Page<OrderOperateHistory>> page(@RequestBody Page<OrderOperateHistory> page) {
        orderOperateHistoryService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除订单操作历史记录信息")
    public BaseResult<Long> delete(Long id) {
        orderOperateHistoryService.removeById(id);
        return BaseResult.success(id);
    }
}

